package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Jaani Francis Nickolas
 * Date: 19/9/13
 * Time: 10:50 PM
 * To change this template use File | Settings | File Templates.
 */
public class MyLibrary {

    String Lib_Name;
    String Lib_Address;
    ArrayList<User> Users = new ArrayList<User>();
    ArrayList<Book> Books = new ArrayList<Book>();
    ArrayList<Movie> Movies = new ArrayList<Movie>();

    public MyLibrary()
    {
        Lib_Name = "Bangalore Public Library";
        Lib_Address = "Whitefield, Bangalore";

        Users.add(new User("111-1111","abc@1111","Mr. One","1111@gmail.com","123456789"));
        Users.add(new User("111-1112","abc@1112","Mr. Two","1112@gmail.com","234567891"));
        Users.add(new User("111-1113","abc@1113","Mr. Three","1113@gmail.com","345678912"));
        Users.add(new User("111-1114","abc@1114","Mr. Four","1114@gmail.com","456789123"));
        Users.add(new User("111-1115","abc@1115","Mr. Five","1115@gmail.com","567891234"));

        Books.add(new Book("ECS600","Engineering","Object-Oriented Programming in C++",4,"978-0672323089","Robert Lafore",4,368.00));
        Books.add(new Book("SPH549","Science","Principles Of Physics",9,"978-8126536047","Halliday",8,447.00));

        Movies.add(new Movie("Cloudy with a Chance of Meatballs 2",2013,"Cody Cameron","N/A"));
        Movies.add(new Movie("Rush",2013,"Ron Howard","8.4"));
        Movies.add(new Movie("Inequality for all",2013,"Jacob Kornbluth","8.3"));
        Movies.add(new Movie("The Shawshank Redemption",1994,"Frank Darabont","9.3"));
        Movies.add(new Movie("The Godfather",1972,"Francis Ford Coppola","9.2"));
        Movies.add(new Movie("The Good, the Bad and the Ugly",1966,"Sergio Leone","9.0"));
        Movies.add(new Movie("The Dark Knight",2008,"Christopher Nolan","9.0"));
        Movies.add(new Movie("Inception",2010,"Christopher Nolan","8.8"));
        Movies.add(new Movie("The Silence of the Lambs",1991,"Jonathan Demme","8.7"));
        Movies.add(new Movie("Psycho",1960,"Alfred Hitchcock","8.6"));
        Movies.add(new Movie("Terminator 2: Judgment Day",1991,"James Cameron","8.6"));
        Movies.add(new Movie("Gladiator",2000,"Ridley Scott","8.5"));
        Movies.add(new Movie("The Lion King",1994,"Roger Allers","8.4"));
        Movies.add(new Movie("Gone with the wind",1939,"Victor Fleming","8.2"));
        Movies.add(new Movie("How to Train Your Dragon",2010,"Dean DeBlois","8.2"));
    }

    public void displayLibraryDetails()
    {
        System.out.println("Library Name: " + Lib_Name);
        System.out.println("Library Address: " + Lib_Address);
    }


    public void displayLibraryBooks()
    {
        for (Book temp_book : Books)
        {
            temp_book.displayBookDetails();
        }
    }

    public boolean reserveBook(String t_bid)
    {
        for (Book temp_book : Books)
        {
            if (temp_book.compareBookID(t_bid) & temp_book.checkAvailability() == true)
            {
                temp_book.confirmReservation();
                return true;
            }
        }
        return false;
    }

    public void displayMovies()
    {
        for (Movie temporaryMovie : Movies)
        {
            temporaryMovie.displayMovieDetails();
        }
    }

    public boolean checkUserDetails(String temporaryUserName, String temporaryPassword)
    {
        for (User temporaryUser : Users)
        {
            if (temporaryUser.validateCredentials(temporaryUserName,temporaryPassword) == true)
                return true;
        }
        return false;
    }

    public void displayUserDetails(String temporaryUserName, String temporaryPassword)
    {
        for (User temporaryUser : Users)
        {
            if (temporaryUser.validateCredentials(temporaryUserName,temporaryPassword) == true)
                temporaryUser.displayUserDetails();
        }
    }
}
